﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Program18
{
    class Program
    {
        static void Main(string[] args)
        {
            int max, min, sum;
            double avg;
            int[] nums = new int[10];
            ArrayList arr = new ArrayList();
            Random rd = new Random();
            
            #region 初始化数组
            while (arr.Count<nums.Length)
            {
                int tmp = rd.Next(1, 100);
                if (!arr.Contains(tmp))
                {
                    arr.Add(tmp);
                }
            }
            for(int i = 0; i < nums.Length; i++)
            {
                nums[i] = (int)arr[i];
                Console.Write(nums[i]+" ");
            }
            Console.WriteLine();
            #endregion
            //out参数
            //out参数要求在方法内部必须赋值，调用方法时也要加上out参数
            Group(nums, out max, out min, out sum, out avg);
            Console.WriteLine(max);
            Console.WriteLine(min);
            Console.WriteLine(sum);
            Console.WriteLine(avg);

            Console.ReadLine();
        }
        public static void Group(int[] nums,out int max,out int min,out int sum,out double avg)
        {
            max = nums[0];
            min = nums[0];
            sum = 0;
            avg = 0;

            for (int i = 0; i < nums.Length; i++)
            {
                if (nums[i] > max)
                {
                    max = nums[i];
                }
                if (nums[i] < min)
                {
                    min = nums[i];
                }
                sum += nums[i];
            }
            avg = (double)sum / nums.Length;
        }
    }
}
